import { reqCategoryList, reqGetBannerList, reqGetFloorList } from '@/api/index'

// home 小仓库
const state = {
  categoryList: [], // 三级联动数据
  bannerList: [], // 轮播图数据
  floorList:[], // floor 数据
}
const mutations = {
  GETCATEGORYLIST(state, value) {
    state.categoryList = value
  },
  GETBANNERLIST(state, value) {
    state.bannerList = value
  },
  GETFLOORLIST(state, value) {
    state.floorList = value
  }
}
const actions = {
  // 获取三级联动数据
  async getCategoryList({ commit }) {
    let res = await reqCategoryList()
    if (res.code == 200) {
      commit('GETCATEGORYLIST', res.data)
    }
  },
  // 获取home 轮播图数据
  async getBannerList({ commit }) {
    let res = await reqGetBannerList()
    if (res.code == 200) {
      commit('GETBANNERLIST', res.data)
    }
  },
  // 获取floor数据
  async getFloorList({ commit }) {
    let res = await reqGetFloorList()
    if (res.code == 200) {
      commit('GETFLOORLIST', res.data)
    }
  }
}
const getters = {}
export default {
  namespaced: true,
  state,
  mutations,
  actions,
  getters
}
